$(document).ready(function(){
    var csrf_token = $("#csrf_token").val();

    // 发送验证码
    $("#sendCode-btn").click(function(e){
        e.preventDefault();
        var email = $("#email").val();

        // 发送验证码
        $.post({
            url: "/cms/sendMail",
            data: {
                csrf_token: csrf_token,
                email: email
            }
        }, function(data){
            if(data.code == "0"){
                swal("成功提示", "发送邮件成功！", "success");
                //success("邮件发送成功！");
            }else{
                console.log("good");
                swal("错误提示", data.errorMsg, "error");
            };
        });

    });

    $("#form").submit(function(e){
        e.preventDefault();
        var email = $("#email").val();
        var captcha = $("#captcha").val();
        $.post({
            url: "/cms/resetMail",
            data: {
                csrf_token: csrf_token,
                email: email,
                captcha: captcha
            }
        }, function(data){
            console.log(data);
            if(data.code == "0"){
                swal("成功提示", "邮箱修改成功！", "success");
                $("#email").val("");
                $("#captcha").val("");
            }else{
                swal("错误提示", data.errorMsg, "error");
            };
        });
    });
})